package com.haochang.chunkvod.view.vod.ScrollView;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.HorizontalScrollView;

/**
 * @author Yangjie
 *         className CustomHorizontalScrollView
 *         created at  2016/8/26  11:48
 *         自定义传递滚动事件的水平滚动控件
 */
public class CustomHorizontalScrollView extends HorizontalScrollView {
    View mView;
    public CustomHorizontalScrollView(Context context, AttributeSet attrs,
                                      int defStyle) {
        super(context, attrs, defStyle);
        // TODO Auto-generated constructor stub
    }

    public CustomHorizontalScrollView(Context context, AttributeSet attrs) {
        super(context, attrs);
        // TODO Auto-generated constructor stub
    }

    public CustomHorizontalScrollView(Context context) {
        super(context);
        // TODO Auto-generated constructor stub
    }

    protected void onScrollChanged(int l, int t, int oldl, int oldt) {
        super.onScrollChanged(l, t, oldl, oldt);
        if (mView != null) {
            mView.scrollTo(l, t);
        }
    }

//    @Override
//    public boolean onTouchEvent(MotionEvent ev) {
//        return false;
//    }

    /**
 *     className CustomHorizontalScrollView
 *     created at  2016/8/26  12:05
 *     设置一个控件跟随CustomHorizontalScrollView一起滚动
 */
    public void setScrollView(View view) {
        mView = view;
    }
}
